{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# A demo of K-Means clustering on the handwritten digits data (using LowRankModels.jl)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Adapted from http://scikit-learn.org/stable/auto_examples/cluster/plot_kmeans_digits.html"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this example we apply K-Means to the digits dataset.\n",
    "\n",
    "As the ground truth is known here, we also apply different cluster quality metrics to judge the goodness of fit of the cluster labels to the ground truth.\n",
    "\n",
    "**IMPORTANT NOTE**: LowRankModels.jl's PCA is correct (though slower than conventional algorithms), but its K-Means does not always converge, as can be seen in the last figure. It's an ongoing effort."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mRecompiling stale cache file /Users/cedric/.julia/lib/v0.6/LowRankModels.ji for module LowRankModels.\n",
      "\u001b[39mWARNING: could not import Base.scale into LowRankModels\n",
      "\n",
      "WARNING: deprecated syntax \"abstract Domain\" at /Users/cedric/.julia/v0.6/LowRankModels/src/domains.jl:22.\n",
      "Use \"abstract type Domain end\" instead.\n",
      "\n",
      "WARNING: deprecated syntax \"abstract Loss\" at /Users/cedric/.julia/v0.6/LowRankModels/src/losses.jl:53.\n",
      "Use \"abstract type Loss end\" instead.\n",
      "\n",
      "WARNING: deprecated syntax \"abstract DiffLoss<:Loss\" at /Users/cedric/.julia/v0.6/LowRankModels/src/losses.jl:56.\n",
      "Use \"abstract type DiffLoss<:Loss end\" instead.\n",
      "\n",
      "WARNING: deprecated syntax \"abstract ClassificationLoss<:Loss\" at /Users/cedric/.julia/v0.6/LowRankModels/src/losses.jl:58.\n",
      "Use \"abstract type ClassificationLoss<:Loss end\" instead.\n",
      "\n",
      "WARNING: deprecated syntax \"abstract Regularizer\" at /Users/cedric/.julia/v0.6/LowRankModels/src/regularizers.jl:30.\n",
      "Use \"abstract type Regularizer end\" instead.\n",
      "\n",
      "WARNING: deprecated syntax \"abstract MatrixRegularizer<:LowRankModels.Regularizer\" at /Users/cedric/.julia/v0.6/LowRankModels/src/regularizers.jl:31.\n",
      "Use \"abstract type MatrixRegularizer<:LowRankModels.Regularizer end\" instead.\n",
      "\n",
      "WARNING: deprecated syntax \"abstract AbstractGLRM\" at /Users/cedric/.julia/v0.6/LowRankModels/src/glrm.jl:7.\n",
      "Use \"abstract type AbstractGLRM end\" instead.\n",
      "\n",
      "WARNING: deprecated syntax \"typealias ObsArray @compat Union{Array{Array{Int,1},1},Array{UnitRange{Int},1}}\" at /Users/cedric/.julia/v0.6/LowRankModels/src/glrm.jl:11.\n",
      "Use \"const ObsArray = @compat Union{Array{Array{Int,1},1},Array{UnitRange{Int},1}}\" instead.\n",
      "WARNING: Method definition (::Type{ArrayViews.UnsafeContiguousView{T, N} where N where T})(Ptr{T}, Int64, Tuple{Vararg{Int64, N}}) in module ArrayViews at /Users/cedric/.julia/v0.6/ArrayViews/src/arrviews.jl:18 overwritten at /Users/cedric/.julia/v0.6/ArrayViews/src/arrviews.jl:26.\n",
      "\n",
      "WARNING: deprecated syntax \"abstract AbstractParams\" at /Users/cedric/.julia/v0.6/LowRankModels/src/fit.jl:5.\n",
      "Use \"abstract type AbstractParams end\" instead.\n",
      "\n",
      "WARNING: deprecated syntax \"typealias Yview Union{ContiguousView{Float64,1,Array{Float64,2}},ContiguousView{Float64,2,Array{Float64,2}}}\" at /Users/cedric/.julia/v0.6/LowRankModels/src/algorithms/proxgrad.jl:92.\n",
      "Use \"const Yview = Union{ContiguousView{Float64,1,Array{Float64,2}},ContiguousView{Float64,2,Array{Float64,2}}}\" instead.\n",
      "WARNING: could not import DataArrays.array into LowRankModels\n",
      "WARNING: could not import DataArrays.array into LowRankModels\n",
      "WARNING: Method definition isnan(DataArrays.NAtype) in module DataArrays at /Users/cedric/.julia/v0.6/DataArrays/src/natype.jl:51 overwritten in module LowRankModels at /Users/cedric/.julia/v0.6/LowRankModels/src/fit_dataframe.jl:249.\n",
      "WARNING: Method definition (::Type{ArrayViews.UnsafeContiguousView{T, N} where N where T})(Ptr{T}, Int64, Tuple{Vararg{Int64, N}}) in module ArrayViews at /Users/cedric/.julia/v0.6/ArrayViews/src/arrviews.jl:18 overwritten at /Users/cedric/.julia/v0.6/ArrayViews/src/arrviews.jl:26.\n",
      "WARNING: Method definition isnan(DataArrays.NAtype) in module DataArrays at /Users/cedric/.julia/v0.6/DataArrays/src/natype.jl:51 overwritten in module LowRankModels at /Users/cedric/.julia/v0.6/LowRankModels/src/fit_dataframe.jl:249.\n"
     ]
    }
   ],
   "source": [
    "using PyPlot    # Pkg.add(\"PyPlot\") to install\n",
    "using ScikitLearn\n",
    "using PyCall\n",
    "using ScikitLearn.Utils: meshgrid\n",
    "using LowRankModels: PCA, KMeans\n",
    "\n",
    "@sk_import datasets: load_digits\n",
    "@pyimport sklearn.metrics as metrics\n",
    "@pyimport sklearn.preprocessing as preprocessing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "n_digits: 10, \t n_samples 1797, \t n_features 64\n",
      "____________________________________________________________________________\n",
      "init    time  inertia    homo   compl  v-meas     ARI AMI  silhouette\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33m!(B::BitArray) is deprecated, use .!(B) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1m!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1mbuild_glrm\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::BitArray{2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:56\u001b[22m\u001b[22m\n",
      " [4] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:75\u001b[22m\u001b[22m\n",
      " [5] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m\n",
      " [6] \u001b[1m#fit!#143\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [7] \u001b[1mbench_k_means\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::String, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./In[5]:22\u001b[22m\u001b[22m\n",
      " [8] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [9] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [10] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [11] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 38\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33mArray{T}(::Type{T}, m::Int) is deprecated, use Array{T}(m) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1mArray\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Type{Union{Int64, Range{Int64}}}, ::Int64\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1mget_yidxs\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{LowRankModels.Loss,1}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/losses.jl:77\u001b[22m\u001b[22m\n",
      " [4] \u001b[1m#fit!#79\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.ConvergenceHistory, ::Bool, ::Array{Any,1}, ::Function, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/algorithms/proxgrad.jl:52\u001b[22m\u001b[22m\n",
      " [5] \u001b[1m(::StatsBase.#kw##fit!)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::StatsBase.#fit!, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./<missing>:0\u001b[22m\u001b[22m\n",
      " [6] \u001b[1mdo_fit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:51\u001b[22m\u001b[22m\n",
      " [7] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:77\u001b[22m\u001b[22m\n",
      " [8] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m\n",
      " [9] \u001b[1m#fit!#143\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [10] \u001b[1mbench_k_means\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::String, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./In[5]:22\u001b[22m\u001b[22m\n",
      " [11] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [12] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [13] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [14] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 38\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33mArray{T, N}(::Type{T}, d::NTuple{N, Int}) is deprecated, use Array{T}(d) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1mArray\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Type{Float64}, ::Tuple{Int64,Int64}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1m#fit!#79\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.ConvergenceHistory, ::Bool, ::Array{Any,1}, ::Function, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/algorithms/proxgrad.jl:65\u001b[22m\u001b[22m\n",
      " [4] \u001b[1m(::StatsBase.#kw##fit!)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::StatsBase.#fit!, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./<missing>:0\u001b[22m\u001b[22m\n",
      " [5] \u001b[1mdo_fit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:51\u001b[22m\u001b[22m\n",
      " [6] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:77\u001b[22m\u001b[22m\n",
      " [7] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m\n",
      " [8] \u001b[1m#fit!#143\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [9] \u001b[1mbench_k_means\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::String, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./In[5]:22\u001b[22m\u001b[22m\n",
      " [10] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [11] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [12] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [13] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 38\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33mArray{T, N}(::Type{T}, d::NTuple{N, Int}) is deprecated, use Array{T}(d) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1mArray\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Type{Float64}, ::Tuple{Int64}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1mAc_mul_B\u001b[22m\u001b[22m at \u001b[1m./linalg/matmul.jl:117\u001b[22m\u001b[22m [inlined]\n",
      " [4] \u001b[1mAc_mul_B\u001b[22m\u001b[22m at \u001b[1m./linalg/rowvector.jl:223\u001b[22m\u001b[22m [inlined]\n",
      " [5] \u001b[1m#row_objective#58\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Union{Int64, Range{Int64}},1}, ::Bool, ::Function, ::LowRankModels.GLRM, ::Int64, ::ArrayViews.ContiguousView{Float64,1,Array{Float64,2}}, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/evaluate_fit.jl:29\u001b[22m\u001b[22m\n",
      " [6] \u001b[1mrow_objective\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.GLRM, ::Int64, ::ArrayViews.ContiguousView{Float64,1,Array{Float64,2}}, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/evaluate_fit.jl:27\u001b[22m\u001b[22m (repeats 2 times)\n",
      " [7] \u001b[1m#fit!#79\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.ConvergenceHistory, ::Bool, ::Array{Any,1}, ::Function, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/algorithms/proxgrad.jl:138\u001b[22m\u001b[22m\n",
      " [8] \u001b[1m(::StatsBase.#kw##fit!)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::StatsBase.#fit!, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./<missing>:0\u001b[22m\u001b[22m\n",
      " [9] \u001b[1mdo_fit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:51\u001b[22m\u001b[22m\n",
      " [10] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:77\u001b[22m\u001b[22m\n",
      " [11] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m\n",
      " [12] \u001b[1m#fit!#143\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [13] \u001b[1mbench_k_means\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::String, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./In[5]:22\u001b[22m\u001b[22m\n",
      " [14] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [15] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [16] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [17] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 38\n",
      "WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.\n",
      "  likely near In[5]:38\n",
      "WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.\n",
      "  likely near In[5]:38\n",
      "WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.\n",
      "  likely near In[5]:38\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33mArray{T, N}(::Type{T}, d::NTuple{N, Int}) is deprecated, use Array{T}(d) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1mArray\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Type{Float64}, ::Tuple{Int64,Int64}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1m#fit!#79\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.ConvergenceHistory, ::Bool, ::Array{Any,1}, ::Function, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/algorithms/proxgrad.jl:65\u001b[22m\u001b[22m\n",
      " [4] \u001b[1m(::StatsBase.#kw##fit!)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::StatsBase.#fit!, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./<missing>:0\u001b[22m\u001b[22m\n",
      " [5] \u001b[1mdo_fit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:51\u001b[22m\u001b[22m\n",
      " [6] \u001b[1m#transform#144\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:95\u001b[22m\u001b[22m\n",
      " [7] \u001b[1mtransform\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:91\u001b[22m\u001b[22m\n",
      " [8] \u001b[1mpredict\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:106\u001b[22m\u001b[22m [inlined]\n",
      " [9] \u001b[1mbench_k_means\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::String, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./In[5]:25\u001b[22m\u001b[22m\n",
      " [10] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [11] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [12] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [13] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 38\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "k-means++   234.99s    NaN   0.189   0.229   0.207   0.108   0.181    -0.041\n",
      "________________________________________________________________________"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33m!(B::BitArray) is deprecated, use .!(B) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1m!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1mbuild_glrm\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::BitArray{2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:56\u001b[22m\u001b[22m\n",
      " [4] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:75\u001b[22m\u001b[22m\n",
      " [5] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m (repeats 2 times)\n",
      " [6] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [7] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [8] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [9] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 45\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33mArray{T}(::Type{T}, m::Int) is deprecated, use Array{T}(m) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1mArray\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Type{Union{Int64, Range{Int64}}}, ::Int64\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1mget_yidxs\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{LowRankModels.Loss,1}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/losses.jl:77\u001b[22m\u001b[22m\n",
      " [4] \u001b[1m#init_svd!#83\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Bool, ::Bool, ::Float64, ::Function, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/initialize.jl:44\u001b[22m\u001b[22m\n",
      " [5] \u001b[1minit_svd!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/initialize.jl:37\u001b[22m\u001b[22m\n",
      " [6] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:76\u001b[22m\u001b[22m\n",
      " [7] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m (repeats 2 times)\n",
      " [8] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [9] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [10] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [11] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 45\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33msqrt{T <: Number}(x::AbstractArray{T}) is deprecated, use sqrt.(x) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1msqrt\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Float64,1}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1m#init_svd!#83\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Bool, ::Bool, ::Float64, ::Function, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/initialize.jl:128\u001b[22m\u001b[22m\n",
      " [4] \u001b[1minit_svd!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/initialize.jl:37\u001b[22m\u001b[22m\n",
      " [5] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:76\u001b[22m\u001b[22m\n",
      " [6] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m (repeats 2 times)\n",
      " [7] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [8] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [9] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [10] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 45\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33msqrt{T <: Number}(x::AbstractArray{T}) is deprecated, use sqrt.(x) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1msqrt\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Float64,1}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1m#init_svd!#83\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Bool, ::Bool, ::Float64, ::Function, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/initialize.jl:129\u001b[22m\u001b[22m\n",
      " [4] \u001b[1minit_svd!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/initialize.jl:37\u001b[22m\u001b[22m\n",
      " [5] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:76\u001b[22m\u001b[22m\n",
      " [6] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m (repeats 2 times)\n",
      " [7] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [8] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [9] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [10] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 45\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33mArray{T, N}(::Type{T}, d::NTuple{N, Int}) is deprecated, use Array{T}(d) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1mArray\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Type{Float64}, ::Tuple{Int64,Int64}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1m#fit!#79\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.ConvergenceHistory, ::Bool, ::Array{Any,1}, ::Function, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/algorithms/proxgrad.jl:65\u001b[22m\u001b[22m\n",
      " [4] \u001b[1m(::StatsBase.#kw##fit!)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::StatsBase.#fit!, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./<missing>:0\u001b[22m\u001b[22m\n",
      " [5] \u001b[1mdo_fit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:51\u001b[22m\u001b[22m\n",
      " [6] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:77\u001b[22m\u001b[22m\n",
      " [7] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m (repeats 2 times)\n",
      " [8] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [9] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [10] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [11] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 45\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33mArray{T, N}(::Type{T}, d::NTuple{N, Int}) is deprecated, use Array{T}(d) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1mArray\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Type{Float64}, ::Tuple{Int64}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1mAc_mul_B\u001b[22m\u001b[22m at \u001b[1m./linalg/matmul.jl:117\u001b[22m\u001b[22m [inlined]\n",
      " [4] \u001b[1mAc_mul_B\u001b[22m\u001b[22m at \u001b[1m./linalg/rowvector.jl:223\u001b[22m\u001b[22m [inlined]\n",
      " [5] \u001b[1m#row_objective#58\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Union{Int64, Range{Int64}},1}, ::Bool, ::Function, ::LowRankModels.GLRM, ::Int64, ::ArrayViews.ContiguousView{Float64,1,Array{Float64,2}}, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/evaluate_fit.jl:29\u001b[22m\u001b[22m\n",
      " [6] \u001b[1mrow_objective\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.GLRM, ::Int64, ::ArrayViews.ContiguousView{Float64,1,Array{Float64,2}}, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/evaluate_fit.jl:27\u001b[22m\u001b[22m (repeats 2 times)\n",
      " [7] \u001b[1m#fit!#79\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.ConvergenceHistory, ::Bool, ::Array{Any,1}, ::Function, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/algorithms/proxgrad.jl:138\u001b[22m\u001b[22m\n",
      " [8] \u001b[1m(::StatsBase.#kw##fit!)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::StatsBase.#fit!, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./<missing>:0\u001b[22m\u001b[22m\n",
      " [9] \u001b[1mdo_fit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:51\u001b[22m\u001b[22m\n",
      " [10] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:77\u001b[22m\u001b[22m\n",
      " [11] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m (repeats 2 times)\n",
      " [12] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [13] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [14] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [15] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 45\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fitting GLRM\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[33m!(B::BitArray) is deprecated, use .!(B) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1m!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1mbuild_glrm\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::BitArray{2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:56\u001b[22m\u001b[22m\n",
      " [4] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:75\u001b[22m\u001b[22m\n",
      " [5] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m\n",
      " [6] \u001b[1m#fit!#143\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [7] \u001b[1mfit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [8] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [9] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [10] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [11] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 48\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33mArray{T}(::Type{T}, m::Int) is deprecated, use Array{T}(m) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1mArray\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Type{Union{Int64, Range{Int64}}}, ::Int64\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1mget_yidxs\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{LowRankModels.Loss,1}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/losses.jl:77\u001b[22m\u001b[22m\n",
      " [4] \u001b[1m#fit!#79\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.ConvergenceHistory, ::Bool, ::Array{Any,1}, ::Function, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/algorithms/proxgrad.jl:52\u001b[22m\u001b[22m\n",
      " [5] \u001b[1m(::StatsBase.#kw##fit!)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::StatsBase.#fit!, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./<missing>:0\u001b[22m\u001b[22m\n",
      " [6] \u001b[1mdo_fit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:51\u001b[22m\u001b[22m\n",
      " [7] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:77\u001b[22m\u001b[22m\n",
      " [8] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m\n",
      " [9] \u001b[1m#fit!#143\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [10] \u001b[1mfit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [11] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [12] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [13] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [14] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 48\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33mArray{T, N}(::Type{T}, d::NTuple{N, Int}) is deprecated, use Array{T}(d) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1mArray\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Type{Float64}, ::Tuple{Int64,Int64}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1m#fit!#79\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.ConvergenceHistory, ::Bool, ::Array{Any,1}, ::Function, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/algorithms/proxgrad.jl:65\u001b[22m\u001b[22m\n",
      " [4] \u001b[1m(::StatsBase.#kw##fit!)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::StatsBase.#fit!, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./<missing>:0\u001b[22m\u001b[22m\n",
      " [5] \u001b[1mdo_fit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:51\u001b[22m\u001b[22m\n",
      " [6] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:77\u001b[22m\u001b[22m\n",
      " [7] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m\n",
      " [8] \u001b[1m#fit!#143\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [9] \u001b[1mfit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [10] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [11] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [12] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [13] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 48\n",
      "\u001b[1m\u001b[33mWARNING: \u001b[39m\u001b[22m\u001b[33mArray{T, N}(::Type{T}, d::NTuple{N, Int}) is deprecated, use Array{T}(d) instead.\u001b[39m\n",
      "Stacktrace:\n",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:64\u001b[22m\u001b[22m\n",
      " [2] \u001b[1mArray\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Type{Float64}, ::Tuple{Int64}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m\n",
      " [3] \u001b[1mAc_mul_B\u001b[22m\u001b[22m at \u001b[1m./linalg/matmul.jl:117\u001b[22m\u001b[22m [inlined]\n",
      " [4] \u001b[1mAc_mul_B\u001b[22m\u001b[22m at \u001b[1m./linalg/rowvector.jl:223\u001b[22m\u001b[22m [inlined]\n",
      " [5] \u001b[1m#row_objective#58\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Union{Int64, Range{Int64}},1}, ::Bool, ::Function, ::LowRankModels.GLRM, ::Int64, ::ArrayViews.ContiguousView{Float64,1,Array{Float64,2}}, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/evaluate_fit.jl:29\u001b[22m\u001b[22m\n",
      " [6] \u001b[1mrow_objective\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.GLRM, ::Int64, ::ArrayViews.ContiguousView{Float64,1,Array{Float64,2}}, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/evaluate_fit.jl:27\u001b[22m\u001b[22m (repeats 2 times)\n",
      " [7] \u001b[1m#fit!#79\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.ConvergenceHistory, ::Bool, ::Array{Any,1}, ::Function, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/algorithms/proxgrad.jl:138\u001b[22m\u001b[22m\n",
      " [8] \u001b[1m(::StatsBase.#kw##fit!)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::StatsBase.#fit!, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./<missing>:0\u001b[22m\u001b[22m\n",
      " [9] \u001b[1mdo_fit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:51\u001b[22m\u001b[22m\n",
      " [10] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:77\u001b[22m\u001b[22m\n",
      " [11] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m\n",
      " [12] \u001b[1m#fit!#143\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [13] \u001b[1mfit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m\n",
      " [14] \u001b[1minclude_string\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::String\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:485\u001b[22m\u001b[22m\n",
      " [15] \u001b[1mexecute_request\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket, ::IJulia.Msg\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/execute_request.jl:156\u001b[22m\u001b[22m\n",
      " [16] \u001b[1meventloop\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::ZMQ.Socket\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/IJulia/src/eventloop.jl:8\u001b[22m\u001b[22m\n",
      " [17] \u001b[1m(::IJulia.##9#12)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./task.jl:335\u001b[22m\u001b[22m\n",
      "while loading In[5], in expression starting on line 48\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration 10: objective value = 215.57489659627504\n"
     ]
    },
    {
     "ename": "LoadError",
     "evalue": "\u001b[91mInterruptException:\u001b[39m",
     "output_type": "error",
     "traceback": [
      "\u001b[91mInterruptException:\u001b[39m",
      "",
      "Stacktrace:",
      " [1] \u001b[1mdepwarn\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::String, ::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:65\u001b[22m\u001b[22m",
      " [2] \u001b[1mArray\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Type{Union{Int64, Range{Int64}}}, ::Int64\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./deprecated.jl:51\u001b[22m\u001b[22m",
      " [3] \u001b[1mget_yidxs\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{LowRankModels.Loss,1}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/losses.jl:77\u001b[22m\u001b[22m",
      " [4] \u001b[1mrow_objective\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.GLRM, ::Int64, ::ArrayViews.ContiguousView{Float64,1,Array{Float64,2}}, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/evaluate_fit.jl:27\u001b[22m\u001b[22m (repeats 2 times)",
      " [5] \u001b[1m#fit!#79\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.ConvergenceHistory, ::Bool, ::Array{Any,1}, ::Function, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/algorithms/proxgrad.jl:146\u001b[22m\u001b[22m",
      " [6] \u001b[1m(::StatsBase.#kw##fit!)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::StatsBase.#fit!, ::LowRankModels.GLRM, ::LowRankModels.ProxGradParams\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./<missing>:0\u001b[22m\u001b[22m",
      " [7] \u001b[1mdo_fit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::LowRankModels.GLRM\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:51\u001b[22m\u001b[22m",
      " [8] \u001b[1m#fit_transform!#142\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::BitArray{2}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:77\u001b[22m\u001b[22m",
      " [9] \u001b[1mfit_transform!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:72\u001b[22m\u001b[22m",
      " [10] \u001b[1m#fit!#143\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::Function, ::LowRankModels.SkGLRM, ::Array{Float64,2}, ::Void\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m",
      " [11] \u001b[1mfit!\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::LowRankModels.SkGLRM, ::Array{Float64,2}\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/Users/cedric/.julia/v0.6/LowRankModels/src/scikitlearn.jl:83\u001b[22m\u001b[22m"
     ]
    }
   ],
   "source": [
    "srand(42)\n",
    "\n",
    "digits = load_digits()\n",
    "data = preprocessing.scale(digits[\"data\"])\n",
    "\n",
    "n_samples, n_features = size(data)\n",
    "n_digits = length(unique(digits[\"target\"]))\n",
    "labels = digits[\"target\"]\n",
    "\n",
    "sample_size = 300\n",
    "\n",
    "@printf(\"n_digits: %d, \\t n_samples %d, \\t n_features %d\\n\", n_digits, n_samples, n_features)\n",
    "\n",
    "\n",
    "println(\"____________________________________________________________________________\")\n",
    "@printf(\"% 9s\", \"init    time  inertia    homo   compl  v-meas     ARI AMI  silhouette\\n\")\n",
    "\n",
    "function bench_k_means(estimator, name, data)\n",
    "    t0 = time()\n",
    "    global esti = estimator\n",
    "    global dataa = data\n",
    "    fit!(estimator, data)\n",
    "    # This performs the \"argmax\" over the columns to get the labels\n",
    "    #est_labels = mapslices(indmax, estimator.glrm.X, 1)[:]\n",
    "    est_labels = predict(estimator, data)\n",
    "    @printf(\"% 9s   %.2fs    %i   %.3f   %.3f   %.3f   %.3f   %.3f    %.3f\\n\",\n",
    "            name, time()-t0, NaN,\n",
    "            metrics.homogeneity_score(labels, est_labels),\n",
    "            metrics.completeness_score(labels, est_labels),\n",
    "            metrics.v_measure_score(labels, est_labels),\n",
    "            metrics.adjusted_rand_score(labels, est_labels),\n",
    "            metrics.adjusted_mutual_info_score(labels,  est_labels),\n",
    "            metrics.silhouette_score(data, est_labels,\n",
    "                                      metric=\"euclidean\",\n",
    "                                      sample_size=sample_size))\n",
    "end\n",
    "\n",
    "bench_k_means(KMeans(k=n_digits, max_iter=200), \"k-means++\", data)\n",
    "\n",
    "print(\"________________________________________________________________________\")\n",
    "\n",
    "###############################################################################\n",
    "# Visualize the results on PCA-reduced data\n",
    "\n",
    "reduced_data = fit_transform!(PCA(k=2, max_iter=100), data)\n",
    "\n",
    "kmeans = KMeans(k=n_digits, abs_tol=1.e-10, max_iter=50000, verbose=true, inner_iter=60)\n",
    "fit!(kmeans, reduced_data);\n",
    "\n",
    "#@time Z2 = pairwise(Euclidean(), hcat(xx[:], yy[:])', kmeans.glrm.Y')\n",
    "#predictions = mapslices(indmin, Z2, 2)[:];\n",
    "\n",
    "# Step size of the mesh. Decrease to increase the quality of the VQ.\n",
    "h = .02     # point in the mesh [x_min, m_max]x[y_min, y_max].\n",
    "\n",
    "# Plot the decision boundary. For that, we will assign a color to each\n",
    "x_min, x_max = minimum(reduced_data[:, 1]), maximum(reduced_data[:, 1])\n",
    "y_min, y_max = minimum(reduced_data[:, 2]), maximum(reduced_data[:, 2])\n",
    "xx, yy = meshgrid(x_min:h:x_max, y_min:h:y_max);\n",
    "\n",
    "# Obtain labels for each point in mesh. Use last trained model.\n",
    "@time Z0 = predict(kmeans, hcat(xx[:], yy[:]))\n",
    "\n",
    "# Put the result into a color plot\n",
    "Z = reshape(Z0, size(xx)...)\n",
    "\n",
    "imshow(Z, interpolation=\"nearest\",\n",
    "       extent=(minimum(xx), maximum(xx), minimum(yy), maximum(yy)),\n",
    "       cmap=PyPlot.cm[:Paired],\n",
    "       aspect=\"auto\", origin=\"lower\")\n",
    "\n",
    "plot(reduced_data[:, 1], reduced_data[:, 2], \"k.\", markersize=2)\n",
    "# Plot the centroids as a white X\n",
    "#centroids = kmeans[:cluster_centers_]\n",
    "#scatter(centroids[:, 1], centroids[:, 2],\n",
    "#        marker=\"x\", s=169, linewidths=3,\n",
    "#        color=\"w\", zorder=10)\n",
    "title(\"K-means clustering on the digits dataset (PCA-reduced data)\\n\"*\"Centroids are marked with white cross\")\n",
    "xlim(x_min, x_max)\n",
    "ylim(y_min, y_max)\n",
    "xticks(())\n",
    "yticks(())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Julia 0.6.0-pre.alpha",
   "language": "julia",
   "name": "julia-0.6"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "0.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
